<?php
/**
 * Created by 张彪.
 * User: 小马出行
 * Date: 2018/1/11
 * Time: 11:18
 */
namespace app\inter\model;
use app\inter\model\InterBase;
use think\Db;

class DriverModel extends InterBase
{
    public function addDriver($data,$config='')
    {
        $config = $config?:$this->config;
        return Db::connect($config)->name('driver')->insertGetId($data);
    }

    public function getDriver($map=array(),$field='*',$flag=true,$page=1,$limit=10,$config='')
    {
        $config = $config?:$this->config;
        return $flag ? Db::connect($config)->table('xm_driver_base a')->join(['xm_driver_info'=>'b'], 'a.driver_id = b.driver_id', 'LEFT')
            ->where($map)->field($field)->page($page,$limit)->order('a.driver_id desc')->select()
            :Db::connect($config)->table('xm_driver_base a')->join(['xm_driver_info'=>'b'],'a.driver_id = b.driver_id', 'LEFT')->where($map)->field($field)->find();
    }

    public function updateDriver($map,$data,$config='')
    {
        $config = $config?:$this->config;
        return Db::table('xm_driver_base')->where($map)->update($data);
    }

}